function deleteById(id, y) {
    if (confirm("确认删除吗?")) {
        $.post("/goods/delById", {id: id}, function (data) {
            if (data == "true") {
                alert("删除成功!");
                $(y).parent().parent().remove();
            } else {
                alert("删除失败!");
            }
        })
    }
}


$(function () {
    $.post("/tclassify/sel", {id: 0}, function (data) {
        for (let i = 0; i < data.length; i++) {
            $("#classifyLevel1").append(`<option value="${data[i].id}">${data[i].classifyName}</option>`);
        }
    }, "json")


    $("#classifyLevel1").change(function () {
        let html = `<option value="" selected="selected">请选择...</option>`;
        $.post("/tclassify/sel", {id: $(this).val()}, function (data) {
            for (let i = 0; i < data.length; i++) {
                html += `<option value="${data[i].id}">${data[i].classifyName}</option>`;
            }
            $("#classifyLevel2").html(html);
        }, "json")
    })

    $("#classifyLevel2").change(function () {
        let html = `<option value="" selected="selected">请选择...</option>`;
        $.post("/tclassify/sel", {id: $(this).val()}, function (data) {
            for (let i = 0; i < data.length; i++) {
                html += `<option value="${data[i].id}">${data[i].classifyName}</option>`;
            }
            $("#classifyLevel3").html(html);
        }, "json")
    })

    $("#goodsAdd").submit(function () {
        let is = true;
        $("#goodsAdd select").each(function () {
            if ($(this).val() == 0) {
                is = false;
                return false;
            }
        });

        $("#goodsAdd input").each(function () {
            if ($(this).val() == "") {
                is = false;
                return false;
            }
        });

        if (!is) {
            alert("请填写完整信息!");
            return false;
        }

    })
})